package com.itheima.pxgl.cotroller;


import com.itheima.pxgl.common.Result;
import com.itheima.pxgl.common.context.BaseContext;
import com.itheima.pxgl.entity.pojo.Novel;
import com.itheima.pxgl.entity.vo.NovelVo;
import com.itheima.pxgl.service.INovelService;
import com.itheima.pxgl.service.impl.NovelServiceImpl;
import jakarta.websocket.server.PathParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 九尾
 * @since 2024-05-19
 */
@RestController
@RequestMapping("/novel")
@Slf4j
public class NovelController {
    @Autowired
    private INovelService novelService;

    /**
     * 获取作者的全部书籍
//     * @param id
     * @return
     */
    @GetMapping("")
    public Result<List<Novel>> getNovelList(){
        log.info("获取作者的全部书籍");
        List<Novel> novel =  novelService.getNovelListByid();
        return  Result.success(novel);
    }
    @PostMapping("")
    public Result insertNovel(@RequestBody NovelVo novelVo){
        log.info("添加作品{}",novelVo);
        novelService.insertNovel(novelVo);
        return Result.success();
    }
}
